/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sourceryobjects;
import java.io.Serializable;
import sourcery.GraphicsContext;

/**
 *
 * @author claire
 */
public class sNode implements Serializable {
    private sPoint pull;
    private sPoint location;
    private static final double SIZE = 30.0;
    private static final double DAMPEN = 0.1;
    private String name;

    public void setName(String name) { this.name = name; }
    public String getName() { return name; }
    
    public sNode(double x, double y) {
        this.location = new sPoint (x,y);
        this.pull = new sPoint (0,0);
    }

    public sPoint getCoords() {
        return location;
    }

    public void draw(GraphicsContext gc) {
        // Placeholder; object should draw all its attachments~
        gc.DrawNode(location.getX()-SIZE/2.0, location.getY()-SIZE/2.0, SIZE, GraphicsContext.NodeType.BASEOBJECT);
    }


    public sNode collide(sPoint point) {
        sNode d = null;
        double k = this.location.distance(point);
        if(k<30) {
            d = this;
        }
        return d;
    }
    public void pull(sPoint d) {
        pull.add(d);
    }

    public void update() {
        location = location.plus(pull.scale(DAMPEN));
        pull = new sPoint(0,0);
    }

}
